package com.moon.game.command.guest.hunt;

import com.moon.game.command.BaseCmd;
import com.moon.game.command.RequestSession;
import com.moon.game.constants.ErrorCode;
import com.moon.game.exception.GException;
import com.moon.game.manager.PlayerMG;
import com.moon.game.resource.model.Monster;
import com.moon.game.service.FightService;
import com.moon.game.vos.ErrorMsg;
import com.moon.game.vos.PlayerVo;

/**
 * @description 查看怪物信息
 * @author Ranger 作者 E-mail:haozi000005@163.com
 * @version 创建时间：2012-5-11 下午3:35:17
 */
public class ViewMonsterCmd extends BaseCmd{
	@Override
	protected void runOnce(RequestSession req) throws GException {
		switch (req.getStatus()) {
		case STATU_INIT:
			doInit(req);
			break;
		case STATU_CHECK:
			doCheckSelf(req);
			break;
		case STATU_RETURN:
			doResponse(req);
		default:
			break;
		}
	}
	@Override
	protected void doResponse(RequestSession req) throws GException {
		PlayerVo player = PlayerMG.instance.getPlayer(req.getPlayerId());
		String[] ps = req.getClientRequest().getPs();
		if (ps == null || ps.length < 1) {
			doResponseErrorMsg(req, ErrorMsg.build(ErrorCode.ERR_PAR, "参数请求错误"));
			return;
		}
		String monsterId = ps[0];
		Monster monster = FightService.doFindMonsterById(player.getLocation(),monsterId);
		req.setVO("the_monster", monster);
		req.setVO(PAR_PLAYER, player);
		response(req, req.getClientResponse());
	}

}
